<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/28
 * Time: 11:08
 */

namespace app\Model;


use think\Model;
//订单表模型
class OrderModel extends Model
{
    protected $resultSetType = 'collection';
    protected $table = 'tp_order';
/*
 * 订单状态转换
 */
    public function getStatus()
    {
        $getStatus=[
            0 => "待确认",
            1 => "已确认",
            2 => "已完成",
            3 => "已取消",
        ];
        return $getStatus;
    }
    /*
     * 订单状态转换中文
     * $status 字段
     * $value 值
     * 返回单个值
     */
    public static function RrderToName($status,$value)
    {
        $statusKV=[
            'order_status'=>[0 => "取消确认",1 => "已确认",2 => "已完成",3 =>  "已取消"],//订单状态
            "shipping_status"=>[0=>"已发货",1=>"取消发货",2=>"已收货"],//发货状态
            "pay_status"=>[0=>"未支付",1=>"已支付"],//支付状态
        ];

        foreach($statusKV as $k=>$v){
            if ($status==$k){
                $status = $v;
            }
        }
        return $status[$value];
    }
    /*
    * 订单状态转换中文（复数）
    * 返回多个值
    */
    public static function RrderToNames()
    {
        $statusKV=[
            'order_status'=>[0 => "待确认",1 => "已确认",2 => "已收货",3 =>  "已取消",4 =>  "已完成", 5 => "已作废"],//订单状态
            "shipping_status"=>[0=>"未发货",1=>"已发货",2=>"部分发货"],//发货状态
            "pay_status"=>[0=>"未支付",1=>"已支付"],//支付状态
        ];
        return $statusKV;
    }
}